package com.itheima.demo.demo11;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //服务端
        ServerSocket sev=new ServerSocket(8888);
        Socket socket = sev.accept();
        //这里的accept代表我从客户端接收来到的消息
        //接收客户端发来的消息
        InputStream is=  socket.getInputStream();
        //用输入流读取客户端发来的消息
        byte[]buf=new byte[1024];
        int read = is.read(buf);
        System.out.println(new String(buf,0,read));
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("飞机".getBytes());

        socket.close();
        outputStream.close();


    }
}
